import 'package:app/common/product_card.dart';
import 'package:app/common/save_update.dart';
import 'package:app/model/product_view_model.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'global.dart';
class ProductShopCard extends StatelessWidget {
  final ProductViewModel data;
  //final ValueChanged<bool> addCount;
  //final int shopCartCount;

  const ProductShopCard({
    Key key,
    this.data,
    //this.shopCartCount,
    //this.addCount,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      padding: EdgeInsets.all(15),
      child: Row(
        children: <Widget>[
          ClipRRect(
            borderRadius: BorderRadius.circular(4),
            child: Image.asset(
              "assets/201905141517518.png",
              width: 40,
              height: 40,
            ),
          ),
          Padding(padding: EdgeInsets.only(left: 15)),
          Expanded(
            child: Column(
              //padding: EdgeInsets.only(top: 5),
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: <Widget>[
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                  Expanded(
                    child:Consumer<GlobalData>(
                        builder: (context,globalData,_)=>Text(
                          this.data.productName,
                          style: TextStyle(
                            fontSize: 16,
                            fontWeight: FontWeight.w500,
                            color: globalData.currentTheme,
                          ),
                        )),
                    )
                  ],
                ),
                Padding(padding: EdgeInsets.only(top: 5)),
                Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  //EdgeInsets.all(10.0),
                  children: <Widget>[
                    Text(
                        "代理价: "+this.data.priceBig,
                        //maxLines: 12,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                          fontSize: 14,
                          color: Color(0xFF999999),
                        ),
                      ),
                    Padding(padding: EdgeInsets.only(left: 45)),
                    Text(
                        "售价: "+this.data.priceSale,
                        //maxLines: 12,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                          fontSize: 14,
                          color: Color(0xFF999999),
                        ),
                      ),
              ],
            ),
          ])),
            Consumer<GlobalData>(
                builder: (context,globalData,_)=>IconButton(
                      icon:Icon(Icons.delete,color:globalData.currentTheme ,),
                      onPressed:(){
                       Provider.of<GlobalData>(context).minusShopCartCount(data);
                       //Provider.of<GlobalData>(context).addShopCartCount();
                      }
                ),
              ),
        ],
      ),
    );
  }

}
